New to SE, needed to reformat my other question. Basically I'm looking at reading a CSV with longitude and latitude points (in this case housing exposure, simplified below):
HUC4,Longitude,Latitude1204,-95.956,30.051204,-95.955,30.048And I would like to create a grid for each point in the form below. In my case I need to take the cell resolution (roughly 0.001) and increase this to around 30m or roughly 0.00025 decimal degrees.
newres = 0.00025csvinput = open(file, 'r')reader = csv.DictReader(csvinput, delimiter=',')dst_file = open("out.csv",'wt')dst_file.write( "longitude,latitude,huc4\n" )lformat = '%.5f,%.5f,%5s'for row in reader: huc4 = row['HUC4'] # Longitude Value x = float(row["Longitude"]) xup = x + newres xdwn = x - newres # Latitude values y = float(row["Latitude"]) yup = y + newres ydwn = y - newresxup ,ydwn | xup, y | xup , yupx ,ydwn | x, y | x , yupxdwn ,ydwn | xdwn,y | xdwn, yupThen I just append each row to a new CSV. It's not very efficient.
I'm curious if there's an easier way to do this that doesn't involve raster creation and re-sampling. Ideally I would think that I can take the x/y values and create an array that I can just multiply by
longarray = [xup, x, xdwn, xup, x, xdwn, xup, x, xdwn]latarray = [ydwn, ydwn, ydwn, y, y, y, yup, yup, yup]Bottom line, I need to make sure that I am increasing the resolution of these points by a certain factor and I'm scared that if I create a grid out of the points and use GDAL, I will get some floating point errors later.
Any help / pointing me towards the right place would be lovely. Thanks!
أكثر...
HUC4,Longitude,Latitude1204,-95.956,30.051204,-95.955,30.048And I would like to create a grid for each point in the form below. In my case I need to take the cell resolution (roughly 0.001) and increase this to around 30m or roughly 0.00025 decimal degrees.
newres = 0.00025csvinput = open(file, 'r')reader = csv.DictReader(csvinput, delimiter=',')dst_file = open("out.csv",'wt')dst_file.write( "longitude,latitude,huc4\n" )lformat = '%.5f,%.5f,%5s'for row in reader: huc4 = row['HUC4'] # Longitude Value x = float(row["Longitude"]) xup = x + newres xdwn = x - newres # Latitude values y = float(row["Latitude"]) yup = y + newres ydwn = y - newresxup ,ydwn | xup, y | xup , yupx ,ydwn | x, y | x , yupxdwn ,ydwn | xdwn,y | xdwn, yupThen I just append each row to a new CSV. It's not very efficient.
I'm curious if there's an easier way to do this that doesn't involve raster creation and re-sampling. Ideally I would think that I can take the x/y values and create an array that I can just multiply by
longarray = [xup, x, xdwn, xup, x, xdwn, xup, x, xdwn]latarray = [ydwn, ydwn, ydwn, y, y, y, yup, yup, yup]Bottom line, I need to make sure that I am increasing the resolution of these points by a certain factor and I'm scared that if I create a grid out of the points and use GDAL, I will get some floating point errors later.
Any help / pointing me towards the right place would be lovely. Thanks!
أكثر...