Git Product home page Git Product logo

scipy2018-geospatial-data's Introduction

pypi Actions Status Coverage Status Join the chat at https://gitter.im/geopandas/geopandas Binder DOI Powered by NumFOCUS

GeoPandas

Python tools for geographic data

Introduction

GeoPandas is a project to add support for geographic data to pandas objects. It currently implements GeoSeries and GeoDataFrame types which are subclasses of pandas.Series and pandas.DataFrame respectively. GeoPandas objects can act on shapely geometry objects and perform geometric operations.

GeoPandas geometry operations are cartesian. The coordinate reference system (crs) can be stored as an attribute on an object, and is automatically set when loading from a file. Objects may be transformed to new coordinate systems with the to_crs() method. There is currently no enforcement of like coordinates for operations, but that may change in the future.

Documentation is available at geopandas.org (current release) and Read the Docs (release and development versions).

The GeoPandas project uses an open governance model and is fiscally sponsored by NumFOCUS. Consider making a tax-deductible donation to help the project pay for developer time, professional services, travel, workshops, and a variety of other needs.


Install

See the installation docs for all details. GeoPandas depends on the following packages:

  • pandas
  • shapely
  • pyogrio
  • pyproj
  • packaging

Further, matplotlib is an optional dependency, required for plotting. Those packages depend on several low-level libraries for geospatial analysis, which can be a challenge to install. Therefore, we recommend to install GeoPandas using the conda package manager. See the installation docs for more details.

Get in touch

Examples

>>> import geopandas
>>> from shapely.geometry import Polygon
>>> p1 = Polygon([(0, 0), (1, 0), (1, 1)])
>>> p2 = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])
>>> p3 = Polygon([(2, 0), (3, 0), (3, 1), (2, 1)])
>>> g = geopandas.GeoSeries([p1, p2, p3])
>>> g
0         POLYGON ((0 0, 1 0, 1 1, 0 0))
1    POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))
2    POLYGON ((2 0, 3 0, 3 1, 2 1, 2 0))
dtype: geometry

Example 1

Some geographic operations return normal pandas objects. The area property of a GeoSeries will return a pandas.Series containing the area of each item in the GeoSeries:

>>> print(g.area)
0    0.5
1    1.0
2    1.0
dtype: float64

Other operations return GeoPandas objects:

>>> g.buffer(0.5)
0    POLYGON ((-0.3535533905932737 0.35355339059327...
1    POLYGON ((-0.5 0, -0.5 1, -0.4975923633360985 ...
2    POLYGON ((1.5 0, 1.5 1, 1.502407636663901 1.04...
dtype: geometry

Example 2

GeoPandas objects also know how to plot themselves. GeoPandas uses matplotlib for plotting. To generate a plot of a GeoSeries, use:

>>> g.plot()

GeoPandas also implements alternate constructors that can read any data format recognized by pyogrio. To read a zip file containing an ESRI shapefile with the boroughs boundaries of New York City (the example can be fetched using the geodatasets package):

>>> import geodatasets
>>> nybb_path = geodatasets.get_path('nybb')
>>> boros = geopandas.read_file(nybb_path)
>>> boros.set_index('BoroCode', inplace=True)
>>> boros.sort_index(inplace=True)
>>> boros
               BoroName     Shape_Leng    Shape_Area  \
BoroCode
1             Manhattan  359299.096471  6.364715e+08
2                 Bronx  464392.991824  1.186925e+09
3              Brooklyn  741080.523166  1.937479e+09
4                Queens  896344.047763  3.045213e+09
5         Staten Island  330470.010332  1.623820e+09

                                                   geometry
BoroCode
1         MULTIPOLYGON (((981219.0557861328 188655.31579...
2         MULTIPOLYGON (((1012821.805786133 229228.26458...
3         MULTIPOLYGON (((1021176.479003906 151374.79699...
4         MULTIPOLYGON (((1029606.076599121 156073.81420...
5         MULTIPOLYGON (((970217.0223999023 145643.33221...

New York City boroughs

>>> boros['geometry'].convex_hull
BoroCode
1    POLYGON ((977855.4451904297 188082.3223876953,...
2    POLYGON ((1017949.977600098 225426.8845825195,...
3    POLYGON ((988872.8212280273 146772.0317993164,...
4    POLYGON ((1000721.531799316 136681.776184082, ...
5    POLYGON ((915517.6877458114 120121.8812543372,...
dtype: geometry

Convex hulls of New York City boroughs

scipy2018-geospatial-data's People

Contributors

jarnorfb avatar jorisvandenbossche avatar ljwolf avatar pranjaldhole avatar sjsrey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scipy2018-geospatial-data's Issues

Import errors

libpysal and mapclassify no longer requires api module import

compile error

I ran conda env create -f environment.yml on a new install of anaconda on a windows 7 machine and get the following errors:

  1. Failed building wheel for rasterio
    Running setup.py clean for rasterio
    Failed to build rasterio
    mkl-random 1.0.1 requires cython, which is not installed.
    mkl-fft 1.0.0 requires cython, which is not installed.


Command "c:\users\mlcobb\appdata\local\continuum\anaconda3\envs\scipygeo18\python.exe -u -c "import setuptools, tokenize;file='C:\Users\mlcobb\AppData\Local\Temp\pip-install-l_bqk9xw\rasterio\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\mlcobb\AppData\Local\Temp\pip-record-ccox88lp\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\mlcobb\AppData\Local\Temp\pip-install-l_bqk9xw\rasterio\

CondaValueError: pip returned an error

Any help appreciated.
Thanks,
Mike

geopandas

geopandas failed to install. I manually did with conda and when I try to import get this

In [1]: import geopandas

ImportError Traceback (most recent call last)
in ()
----> 1 import geopandas

~\AppData\Local\Continuum\anaconda3\envs\scipygeo18\lib\site-packages\geopandas_init_.py in ()
2 from geopandas.geodataframe import GeoDataFrame
3
----> 4 from geopandas.io.file import read_file
5 from geopandas.io.sql import read_postgis
6 from geopandas.tools import sjoin

~\AppData\Local\Continuum\anaconda3\envs\scipygeo18\lib\site-packages\geopandas\io\file.py in ()
1 import os
2
----> 3 import fiona
4 import numpy as np
5

~\AppData\Local\Continuum\anaconda3\envs\scipygeo18\lib\site-packages\fiona_init_.py in ()
67 from six import string_types
68
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
70 from fiona._drivers import driver_count, GDALEnv
71 from fiona.drvsupport import supported_drivers

~\AppData\Local\Continuum\anaconda3\envs\scipygeo18\lib\site-packages\fiona\collection.py in ()
7
8 from fiona import compat
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
10 from fiona.ogrext import Session, WritingSession
11 from fiona.ogrext import (

ImportError: DLL load failed: The operating system cannot run %1.

add actual exercises for data science notebooks

This would be to ensure that we can get people doing things, rather than just presenting the concepts.

The way I see it, we could add an exercise pretty quickly to the ESDA stuff.
Also, may want to consider data that's actually binary for the jointcount stuff. I was thinking that a good one in the airbnb data (I use it for another context) is "shortstay" vs. "longstay" neighborhoods, based on whether or not the mode "minimum nights" for listings in a neighborhood is larger than one night.

Also blends nicely to multi-join counts, but we don't have those implemented directly iirc... I just used it with simulations & chi-squared.

So:

  • Exercises for esda
  • Exercises for data borrowing:
    • student fits a novel model on the data
    • student checks if lag works better than nearest k features
    • student checks if distance-to-other-feature works better than a fixed effect
    • student checks if the residuals are correlated using ESDA stuff, map, & LM test.

spatial kernel weight (spatial lag variable) calculated with NAN

Hi,
I am following your data borrowing tutorial to calculate the spatial lag variable('price') with Gaussian kernel weight , it succeeded in find all the closest kW.neighbors but some rows did not get kW.weights, thus not all of the rows got the lag variable(price).

None of the rows of the coordinates geometries or price columns are nan or zero. So I am not sure what went wrong.

error are as follows:

/Users/xxx/miniconda3/lib/python3.6/site-packages/libpysal/weights/distance.py:645: RuntimeWarning: invalid value encountered in true_divide
  zi = np.array([dict(list(zip(ni, di)))[nid] for nid in nids]) / bw[i]
/Users/xxx/miniconda3/lib/python3.6/site-packages/libpysal/weights/weights.py:171: UserWarning: The weights matrix is not fully connected. There are 796 components
  warnings.warn("The weights matrix is not fully connected. There are %d components" % self.n_components)
/Users/xxx/miniconda3/lib/python3.6/site-packages/libpysal/weights/weights.py:171: UserWarning: The weights matrix is not fully connected. There are 796 components
  warnings.warn("The weights matrix is not fully connected. There are %d components" % self.n_components)

Here's the code:

lag_vars=['price']
kW = lp.weights.Kernel.from_dataframe(df.loc[:,lag_vars+['geometry']], fixed=False, function='gaussian', k=10)
kW = fill_diagonal(kW, 0)
kW.transform = 'r'
WX = lp.weights.lag_spatial(kW, df.loc[:,lag_vars])
WXtable = pd.DataFrame(WX, columns=['lag_{}'.format(name) for name in lag_vars])
fd_lag = pd.concat((df,WXtable),axis=1)

GeoPandas errors, is there anybody know how to fix this problem?


ImportError Traceback (most recent call last)
in ()
2
3 import pandas as pd
----> 4 import geopandas
5
6 pd.options.display.max_rows = 10

/anaconda3/lib/python3.7/site-packages/geopandas/init.py in ()
2 from geopandas.geodataframe import GeoDataFrame
3
----> 4 from geopandas.io.file import read_file
5 from geopandas.io.sql import read_postgis
6 from geopandas.tools import sjoin

/anaconda3/lib/python3.7/site-packages/geopandas/io/file.py in ()
1 import os
2
----> 3 import fiona
4 import numpy as np
5 import six

/anaconda3/lib/python3.7/site-packages/fiona/init.py in ()
81 os.environ["PATH"] = os.environ["PATH"] + ";" + libdir
82
---> 83 from fiona.collection import BytesCollection, Collection
84 from fiona.drvsupport import supported_drivers
85 from fiona.env import ensure_env_with_credentials, Env

/anaconda3/lib/python3.7/site-packages/fiona/collection.py in ()
7
8 from fiona import compat, vfs
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
10 from fiona.ogrext import Session, WritingSession
11 from fiona.ogrext import (

ImportError: dlopen(/anaconda3/lib/python3.7/site-packages/fiona/ogrext.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libkea.1.4.7.dylib
Referenced from: /anaconda3/lib/libgdal.20.dylib
Reason: image not found

ERDAS 2018 CRACK INSTALLATION

I am searching ERDAS 2018 crack because of its numerical spatial model application which is not supporting previous version of ERDAS. Kindly someone please suggest me how to use new erdas 2018 crack version

switch to using `residential districts` instead of neighborhoods

this'll avoid terminological conflicts we encountered at geopython with referring to the "neighboring neighborhoods" or neighborhood of the neighborhood.

If we call these polygons districts, then we can clearly discuss districts & the surrounding neighborhood of the district.

Projection in the case-gini notebook

The solution gives:

# %load _solved/solutions/case-trump-vote02.py
pres.crs = {'init':'epsg:4269'}
pres = pres.to_crs(epsg=5070)

Should that be 4326 instead of 4269 ?
Or at least it is not really clear where the participant should get the 4269 from

Why my geometry has nothing to plot

I have download the scipy2018-geospatial-data-master/scipy2018-geospatial-data-master/08-clustering.ipynb

but thre is something wrong, POLYGON ((inf ...inf):
district = gpd.read_file('./data/berlin-districts.geojson').to_crs(epsg=3857)
district.head(10)

district	district_group	median_price	geometry
0	Blankenfelde/Niederschönhausen	Pankow	37.5	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
1	Helmholtzplatz	Pankow	58.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
2	Wiesbadener Straße	Charlottenburg-Wilm.	50.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
3	Schmöckwitz/Karolinenhof/Rauchfangswerder	Treptow - Köpenick	99.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
4	Müggelheim	Treptow - Köpenick	25.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
5	Biesdorf	Marzahn - Hellersdorf	35.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
6	Nord 1	Reinickendorf	31.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
7	West 5	Reinickendorf	50.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
8	Frankfurter Allee Nord	Friedrichshain-Kreuzberg	42.0	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...
9	Buch	Pankow	57.5	(POLYGON ((inf inf, inf inf, inf inf, inf inf,...

and the plot is nothing

geopandas fails on binder

I tried to run the notebooks on binder, but on importing geopandas I get the following error

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-05f10f3f66de> in <module>()
      2 
      3 import pandas as pd
----> 4 import geopandas
      5 
      6 pd.options.display.max_rows = 10

/srv/conda/lib/python3.6/site-packages/geopandas/__init__.py in <module>()
      2 from geopandas.geodataframe import GeoDataFrame
      3 
----> 4 from geopandas.io.file import read_file
      5 from geopandas.io.sql import read_postgis
      6 from geopandas.tools import sjoin

/srv/conda/lib/python3.6/site-packages/geopandas/io/file.py in <module>()
      1 import os
      2 
----> 3 import fiona
      4 import numpy as np
      5 

/srv/conda/lib/python3.6/site-packages/fiona/__init__.py in <module>()
     67 from six import string_types
     68 
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
     70 from fiona._drivers import driver_count, GDALEnv
     71 from fiona.drvsupport import supported_drivers

/srv/conda/lib/python3.6/site-packages/fiona/collection.py in <module>()
      7 
      8 from fiona import compat
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
     10 from fiona.ogrext import Session, WritingSession
     11 from fiona.ogrext import (

ImportError: /srv/conda/lib/python3.6/site-packages/fiona/../../.././libkea.so.1.4: undefined symbol: _ZNK2H58H5Object13openAttributeERKSs

This looks a bit similar to #16

Clear notebooks?

Was checking the 05-mapclassification.ipynb notebook, and the output is still there. Do we want that the participants have a version that they still need to run to see the output, or already with the output included as it is now?

conversion of xml to shape file

I want to convert xml file to shape file making the attribute unchanged. I already tried in Qgis, but after converting into shape file, attribute which was present in the xml file is not visible in the attribute table of the shape file. kindly give some suggestions to convert xml to shape file maintaining the attribute unchanged.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.