GeoPandas परिचय

Python में Geospatial Data के साथ काम करना

Joris Van den Bossche

Open source software developer and teacher, GeoPandas maintainer

स्पैटियल-विशिष्ट डेटा फ़ॉर्मैट्स

restaurants = pd.read_csv("datasets/paris_restaurants.csv")
restaurants.head()
                                             type         x          y
0                             Restaurant européen  259641.6  6251867.4
1                Restaurant traditionnel français  259572.3  6252030.2
2                Restaurant traditionnel français  259657.2  6252143.8
3  Restaurant indien, pakिस्तानी et Moyen Orient  259684.4  6252203.6
4                Restaurant traditionnel français  259597.9  6252230.0

कोर्स के आगे:

  • स्पैटियल फ़ाइल फ़ॉर्मैट्स (Shapefiles, GeoJSON, GeoPackage, ...)
  • GeoPandas: स्पैटियल डेटा सपोर्ट वाले pandas DataFrames
Python में Geospatial Data के साथ काम करना

GeoPandas से जियोस्पैटियल डेटा इम्पोर्ट करना

import geopandas
countries = geopandas.read_file("countries.geojson")
countries.head()
          name      continent       gdp                            geometry
0  Afghanistan           Asia   64080.0  POLYGON ((61.21 35.65, 62.23 35...
1       Angola         Africa  189000.0  MULTIPOLYGON (((23.90 -11.72, 2...
2      Albania         Europe   33900.0  POLYGON ((21.02 40.84, 21.00 40...
4    Argentina  South America  879400.0  MULTIPOLYGON (((-66.96 -54.90, ...
5      Armenia           Asia   26300.0  POLYGON ((43.58 41.09, 44.97 41...
Python में Geospatial Data के साथ काम करना

GeoPandas से स्पैटियल डेटा को जल्दी विज़ुअलाइज़ करें

countries.plot()

Python में Geospatial Data के साथ काम करना

GeoDataFrame

countries.head()
          name      continent       gdp                            geometry
0  Afghanistan           Asia   64080.0  POLYGON ((61.21 35.65, 62.23 35...
1       Angola         Africa  189000.0  MULTIPOLYGON (((23.90 -11.72, 2...
2      Albania         Europe   33900.0  POLYGON ((21.02 40.84, 21.00 40...
...
type(countries)
geopandas.geodataframe.GeoDataFrame
Python में Geospatial Data के साथ काम करना

GeoDataFrame

countries.head()
          name      continent       gdp                            geometry
0  Afghanistan           Asia   64080.0  POLYGON ((61.21 35.65, 62.23 35...
1       Angola         Africa  189000.0  MULTIPOLYGON (((23.90 -11.72, 2...
2      Albania         Europe   33900.0  POLYGON ((21.02 40.84, 21.00 40...
...

GeoDataFrame एक टैब्युलर, जियोस्पैटियल वेक्टर डेटासेट होता है:

  • एक 'geometry' कॉलम: जो ज्योमेट्री जानकारी रखता है
  • अन्य कॉलम: attributes हर ज्योमेट्री का वर्णन करते हैं
Python में Geospatial Data के साथ काम करना

'geometry' एट्रिब्यूट

countries.geometry
0      POLYGON ((61.21 35.65, 62.23 35...
1      MULTIPOLYGON (((23.90 -11.72, 2...
                      ...                
175    POLYGON ((23.22 -17.52, 22.56 -...
176    POLYGON ((29.43 -22.09, 28.79 -...
Name: geometry, Length: 176, dtype: object
type(countries.geometry)
geopandas.geoseries.GeoSeries
Python में Geospatial Data के साथ काम करना

स्पैटियल-अवेयर DataFrame

countries.geometry.area
0       63.593500
1      103.599439
2        3.185163
          ...    
174    112.718524
175     62.789498
176     32.280371
Length: 177, dtype: float64
Python में Geospatial Data के साथ काम करना

सारांश

GeoDataFrame एक pandas DataFrame जैसा है:

  • सामान्य pandas DataFrames की सभी क्षमताएँ काम करती हैं

पर इसमें स्पैटियल फ़ंक्शनैलिटी जोड़ी गई है:

  • plot() मेथड
  • geometry एट्रिब्यूट (GeoSeries)
  • स्पैटियल-विशिष्ट एट्रिब्यूट्स और मेथड्स (जैसे area)
Python में Geospatial Data के साथ काम करना

अभ्यास करते हैं!

Python में Geospatial Data के साथ काम करना

Preparing Video For Download...