Reprojections




Pay Notebook Creator: Salah Ahmed0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0
In [1]:
import geotable
In [2]:
utm_proj4 = geotable.load_utm_proj4('infrastructure/buildings.csv')
In [5]:
buildings = geotable.load('infrastructure/buildings.csv', target_proj4=utm_proj4)
In [6]:
buildings.draw()
Out[6]:
<geotable.ColorfulGeometryCollection at 0x7fcad0e27f98>
In [7]:
buildings.head()
Out[7]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
id tag geometry_layer geometry_proj4 geometry_object
0 1980036505 office buildings +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs POINT (343686.209287758 536887.885548674)
1 1980036524 public buildings +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs POINT (346710.3969804449 536665.4266674238)
2 1980036532 office buildings +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs POINT (345229.0166323374 536303.073127988)
3 1980036556 public buildings +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs POINT (345551.6779001815 536559.8291174495)
4 1980071144 office buildings +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs POINT (344709.6269702117 536448.7610854662)
In [18]:
buildings['geometry_object'][:10]
Out[18]:
0      POINT (343686.209287758 536887.885548674)
1    POINT (346710.3969804449 536665.4266674238)
2     POINT (345229.0166323374 536303.073127988)
3    POINT (345551.6779001815 536559.8291174495)
4    POINT (344709.6269702117 536448.7610854662)
5    POINT (346849.4987384675 536375.8023435167)
6     POINT (345953.6722010225 536476.351729591)
7    POINT (346157.6366554421 535911.9903629068)
8    POINT (346978.4549705453 536408.2462068899)
9    POINT (342768.1220636999 536654.8600059842)
Name: geometry_object, dtype: object
In [11]:
buildings['geometry_object'][0]
Out[11]:
<shapely.geometry.point.Point at 0x7fcadf520fd0>
In [13]:
state = geotable.load('ssd/ssd_admbnda_adm2_imwg_nbs_20180817.shp', target_proj4=utm_proj4)
In [14]:
state.draw()
Out[14]:
<geotable.ColorfulGeometryCollection at 0x7fcad043d438>
In [15]:
state.head()
Out[15]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
Shape_Leng Shape_Area ADM2_EN ADM2_PCODE ADM2_REF ADM2ALT1EN ADM2ALT2EN ADM1_EN ADM1_PCODE ADM0_EN ADM0_PCODE date validOn ValidTo geometry_object geometry_layer geometry_proj4
0 6.425236 1.497073 Juba SS0101 Central Equatoria SS01 South Sudan SS 2018-08-15 2018-08-17 NaN POLYGON ((400533.2188367627 593402.1280940188,... ssd_admbnda_adm2_imwg_nbs_20180817 +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs
1 2.082643 0.204872 Kajo-keji SS0102 Central Equatoria SS01 South Sudan SS 2018-08-15 2018-08-17 NaN POLYGON ((346640.1721883069 444886.8700519086,... ssd_admbnda_adm2_imwg_nbs_20180817 +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs
2 3.402761 0.285030 Lainya SS0103 Central Equatoria SS01 South Sudan SS 2018-08-15 2018-08-17 NaN POLYGON ((298762.0515945219 476058.1911555744,... ssd_admbnda_adm2_imwg_nbs_20180817 +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs
3 2.069064 0.106561 Morobo SS0104 Central Equatoria SS01 South Sudan SS 2018-08-15 2018-08-17 NaN POLYGON ((283159.5016063858 422275.0868668135,... ssd_admbnda_adm2_imwg_nbs_20180817 +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs
4 5.221777 0.871158 Terekeka SS0105 Terkeka Central Equatoria SS01 South Sudan SS 2018-08-15 2018-08-17 NaN POLYGON ((280985.487381666 653593.6094210907, ... ssd_admbnda_adm2_imwg_nbs_20180817 +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs
In [19]:
state['geometry_object'][:10]
Out[19]:
0    POLYGON ((400533.2188367627 593402.1280940188,...
1    POLYGON ((346640.1721883069 444886.8700519086,...
2    POLYGON ((298762.0515945219 476058.1911555744,...
3    POLYGON ((283159.5016063858 422275.0868668135,...
4    POLYGON ((280985.487381666 653593.6094210907, ...
5    POLYGON ((200402.1441227912 518231.692251418, ...
6    POLYGON ((528972.634854184 542710.3739893999, ...
7    POLYGON ((517377.4672358804 473663.9715922278,...
8    POLYGON ((725835.3036483008 645979.8485542104,...
9    POLYGON ((581351.663365489 638892.8660187675, ...
Name: geometry_object, dtype: object
In [20]:
state['geometry_object'][0]
Out[20]:
<shapely.geometry.polygon.Polygon at 0x7fcad02b6f28>
In [21]:
from shapely.geometry import GeometryCollection
In [29]:
state_polygon = state['geometry_object'][0]
In [30]:
state_polygon
Out[30]:
<shapely.geometry.polygon.Polygon at 0x7fcad02b6f28>
In [31]:
building_point = buildings['geometry_object'][0]
In [32]:
building_point
Out[32]:
<shapely.geometry.point.Point at 0x7fcadf520fd0>
In [33]:
GeometryCollection([state_polygon, building_point])
Out[33]:
<shapely.geometry.collection.GeometryCollection at 0x7fcad0289908>
In [34]:
state_polygon.contains(building_point)
Out[34]:
True