Excuse my first question being slightly more Numpy and less actual GIS, but it relates to latitude / longitude so I thought I'd give it a shot.
Problem: I have a flat file with latitude and longitude and I'm asked to increase the resolution of these individual points.
Currently I'm given a flat file with latitude/longitude and I'm asked to change the 0.001 resolution (~100m resolution) point grid and create 8 more points turning it into .00025 res (~30m resolution) grid. Example of the XX.XXX reoslution points below:
HUC4,Longitude,Latitude1204,-95.956,30.051204,-95.955,30.048Now I believe this is the basis of pretty much all interpolation on rasters and such, as well as slope and other cell calculations. I have created the very un-pythonic solution for myself:
#Inputcsvinput = open(file, 'r')reader = csv.DictReader(csvinput, delimiter=',')#Outputdst_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 - newres'''#################################################### Make sure we create the new matrix properly######################################################################################################xup ,ydwn | xup, y | xup , yupx ,ydwn | x, y | x , yupxdwn ,ydwn | xdwn,y | xdwn, yup######################################################################################################''' line = (lformat % (float(x),float
, str(huc4))) + '\n' dst_file.write( line ) # X Upper Axis line = (lformat % (float(xup),float
, str(huc4))) + '\n' dst_file.write( line ) line = (lformat % (float(xup),float(ydwn), str(huc4))) + '\n' dst_file.write( line ) line = (lformat % (float(xup),float(yup), str(huc4))) + '\n' dst_file.write( line ) # X Middle Axis line = (lformat % (float(x),float(yup), str(huc4))) + '\n' dst_file.write( line ) line = (lformat % (float(x),float(ydwn), str(huc4))) + '\n' dst_file.write( line ) # X Lower Axis line = (lformat % (float(xdwn),float(ydwn), str(huc4))) + '\n' dst_file.write( line ) line = (lformat % (float(xdwn),float
, str(huc4))) + '\n' dst_file.write( line ) line = (lformat % (float(xdwn),float(yup), str(huc4))) + '\n' dst_file.write( line )Now I am very new to python and I know that there are many ways to enhance this as well as storage, but for my purpose, my colleagues see flat files as easiest right now (though I have been messing with Postgres). Any tips on that end would not fall on deaf ears, but my main concern is the creation of the new points.
Can anyone expand on the type of numpy array algorithm you would use?
Can I just create a master array for x and a master array for y and then combine the two together (sorta like a pandas dataframe?):
longarray = [xup, x, xdwn, xup, x, xdwn, xup, x, xdwn]latarray = [ydwn, ydwn, ydwn, y, y, y, yup, yup, yup]Any help would be appreciated.
Thanks!
أكثر...
Problem: I have a flat file with latitude and longitude and I'm asked to increase the resolution of these individual points.
Currently I'm given a flat file with latitude/longitude and I'm asked to change the 0.001 resolution (~100m resolution) point grid and create 8 more points turning it into .00025 res (~30m resolution) grid. Example of the XX.XXX reoslution points below:
HUC4,Longitude,Latitude1204,-95.956,30.051204,-95.955,30.048Now I believe this is the basis of pretty much all interpolation on rasters and such, as well as slope and other cell calculations. I have created the very un-pythonic solution for myself:
#Inputcsvinput = open(file, 'r')reader = csv.DictReader(csvinput, delimiter=',')#Outputdst_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 - newres'''#################################################### Make sure we create the new matrix properly######################################################################################################xup ,ydwn | xup, y | xup , yupx ,ydwn | x, y | x , yupxdwn ,ydwn | xdwn,y | xdwn, yup######################################################################################################''' line = (lformat % (float(x),float
Can anyone expand on the type of numpy array algorithm you would use?
Can I just create a master array for x and a master array for y and then combine the two together (sorta like a pandas dataframe?):
longarray = [xup, x, xdwn, xup, x, xdwn, xup, x, xdwn]latarray = [ydwn, ydwn, ydwn, y, y, y, yup, yup, yup]Any help would be appreciated.
Thanks!
أكثر...