Created
November 5, 2020 09:07
-
-
Save anil-kk/5775a7e12091b8522e827d83d47a19e6 to your computer and use it in GitHub Desktop.
Map DeSO with Lat,Lon of Area of Interest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import geopandas | |
from shapely.geometry import Point | |
from shapely.geometry.polygon import Polygon | |
#https://www.scb.se/vara-tjanster/oppna-data/oppna-geodata/deso--demografiska-statistikomraden/ | |
#https://www.scb.se/contentassets/923c3627a8a042a5b9215e8ff3bde0a3/deso_2018_v2.zip | |
countries_gdf = geopandas.read_file("DeSO_2018_v2.gpkg") | |
#Convert Coordinate-System | |
countries_gdf = countries_gdf.to_crs({'init': 'epsg:4326'}) | |
countries_gdf.plot(figsize=(25,10)) | |
print(countries_gdf.info()) | |
#Filter Helsingborg DeSO | |
hel_gdf=countries_gdf[countries_gdf.deso.str.startswith('1283')] | |
hel_gdf.plot() | |
point = Point(12.703864574432373, 56.031455361344676) | |
def check_coordinate(polygon_coordinates, point): | |
return Polygon(polygon_coordinates).contains(point) | |
match = lat_lon_df['geometry'].apply(check_coordinate, point=point) | |
lat_lon_df[match] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment