Skip to Content
Mastering Geospatial Analysis with Python
book

Mastering Geospatial Analysis with Python

by Silas Toms, Paul Crickard, Eric van Rees
April 2018
Beginner to intermediate content levelBeginner to intermediate
440 pages
11h 36m
English
Packt Publishing
Content preview from Mastering Geospatial Analysis with Python

Loading CSV with geometry

To ensure that a table (address data from OpenAddresses in this case) with latitude and longitude columns is imported as a geospatial dataset, we have to use the Shapely library's Point class. Each Point geometry is generated from the LON and LAT fields of the address dataset which has been imported:

import geopandas as gdpimport cartoframesimport pandas as pdfrom shapely.geometry import PointAPIKEY = "{API KEY}"cc = cartoframes.CartoContext(base_url='https://{username}.carto.com/',                              api_key=APIKEY)address_df = pd.read_csv(r'data/city_of_juneau.csv')geometry = [Point(xy) for xy in zip(address_df.LON, address_df.LAT)]address_df = address_df.drop(['LON', 'LAT'], axis=1)crs = {'init': 'epsg:4326'}geo_df = gdp.GeoDataFrame(address_df, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Geospatial Analysis with Python

Learning Geospatial Analysis with Python

Joel Lawhead

Publisher Resources

ISBN: 9781788293334Supplemental Content