--
Datameet is a community of Data Science enthusiasts in India. Know more about us by visiting http://datameet.org
---
You received this message because you are subscribed to the Google Groups "datameet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datameet+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Good afternoon, Arun.Is there is a similar map for the Greater Delhi region - slums/jugees?
@Sarath, this link gives link for map of JJ (Jhuggie Jhompri Squatter Settlements/Clusters) clusters in Delhi, apparently the map is hosted in google earth engine which is currently non functional and data lost unrecoverable.
@Arun, the pdf map is having vector details embedded in it, vectors from pdf file can be retrieved as follows, which would avoid time consuming (ray tracing based) digitisation of pdf maps, however the resultant vector have to be geo referenced further.
inkscape thepdfmap.pdf --export-plain-svg=thepdfmap.svg
The DXF file can be opened in QGIS and vector can be saved as shape file or Geojson(slumPdf.geojson), the vector file from DXF in QGIS is polyline and it can be converted into polygon as follows
from shapely.geometry import Polygon
import numpy as np
import geopandas as gp
import pandas as pd
ee=gp.read_file('slumPdf.geojson')
ee['lineNo']=np.arange(0,len(ee.index))
xx=[]
yy=[]
lineno=[]
for index, row in ee.iterrows():
for pt in list(row['geometry'].coords):
xx.append(pt[0])
yy.append(pt[1])
lineno.append(row['lineNo'])
db=pd.DataFrame()
db['xx']=xx
db['yy']=yy
db['lineno']=lineno
The above code reads the geojson file and collect x and y coordinates of all vectors’ line strings, I guess this step is the right place to apply geo referencing of vectors
db1=db.drop_duplicates('lineno')
linenos=db1.lineno.tolist()
linenos1=[]
geoslist2=[]
for lineno in linenos:
db2=db[db.lineno==lineno]
if len(db2.index)>=3:
db2['geos'] = db2[['xx', 'yy']].apply(tuple, axis=1)
geoslist=db2.geos.tolist()
geoslist1=Polygon(geoslist)
geoslist2.append(geoslist1)
linenos1.append(lineno)
#print geoslist
else:
#print len(db2.index)
pass
sd=pd.DataFrame()
sd['polyno']=linenos1
sd['geometry']=geoslist2
dfa = gp.GeoDataFrame(sd, columns=['geometry','polyno'], index=sd.index)
dfa.to_file('slumPdfPoly.geojson',driver='GeoJSON')
The above code convert, individual coordinates into polygon, here the line’s having only two coordinates sets are omitted as it can’t be converted into polygon
Using Affine transformations, vectors can be georectified as explained here. It requisites few modification from the above codes. The control points are collected from MapWarper, under its export tab, provided kml file was used. The kml is opened in google earth and the outer most outline of the pdf map was used and GCPs are taken from it
mx=[72.763313,73.000312,72.995965,72.758095]
my=[18.885526,18.888553,19.279235,19.276757]
GeoLyr vector which is the map outline box present in the pdf file. import numpy as np
from skimage.transform import AffineTransform
import math
import geopandas as gp
mx=[72.763313,73.000312,72.995965,72.758095]
my=[18.885526,18.888553,19.279235,19.276757]
dest=[[mx[0],my[0]],[mx[1],my[1]],[mx[2],my[2]],[mx[3],my[3]]]
ee=gp.read_file('slumPdf.geojson')
ee1=ee[ee['Layer']=='GeoLyr']
xx=[]
yy=[]
lineno=[]
for index, row in ee1.iterrows():
for pt in list(row['geometry'].coords):
xx.append(pt[0])
yy.append(pt[1])
source1=[[xx[0],yy[0]],[xx[2],yy[0]],[xx[2],yy[1]],[xx[0],yy[1]]]
source1=np.array(source1)
dest = np.array(dest)
aft3 = AffineTransform()
aft3.estimate(source1, dest)
eegof=ee[ee['Layer']!='GeoLyr']
eegof['lineNo']=np.arange(0,len(eegof.index))
xx=[]
yy=[]
lineno=[]
layer=[]
for index, row in eegof.iterrows():
for pt in list(row['geometry'].coords):
xx.append(pt[0])
yy.append(pt[1])
lineno.append(row['lineNo'])
layer.append(row['Layer'])
db=pd.DataFrame()
db['xx']=xx
db['yy']=yy
db['lineno']=lineno
db['layer']=layer
a0=aft3.params[0,0]
a1=aft3.params[0,1]
a2=aft3.params[0,2]
b0=aft3.params[1,0]
b1=aft3.params[1,1]
b2=aft3.params[1,2]
db['longitude']=(a0*db['xx'].astype(float))+(a1*db['yy'].astype(float))+a2
db['latitude']=(b0*db['xx'].astype(float))+(b1*db['yy'].astype(float))+b2
db1=db.drop_duplicates('lineno')
linenos=db1.lineno.tolist()
linenos1=[]
geoslist2=[]
for lineno in linenos:
db2=db[db.lineno==lineno]
if len(db2.index)>=3:
db2['geos'] = db2[['longitude', 'latitude']].apply(tuple, axis=1)
geoslist=db2.geos.tolist()
geoslist1=Polygon(geoslist)
geoslist2.append(geoslist1)
linenos1.append(lineno)
#print geoslist
else:
#print len(db2.index)
pass
sd=pd.DataFrame()
sd['polyno']=linenos1
sd['geometry']=geoslist2
dfa = gp.GeoDataFrame(sd, columns=['geometry','polyno'], index=sd.index)
dfa.to_file('slumClusters.geojson',driver='GeoJSON')