print('x extent {} : y extent {}'.format(str(x_extent), str(y_extent))) print('Num of 30m pixels in x {} | Num of 30m pixels in y {}'.format( str(xsize), str(ysize))) wkt_list = list( Vector.wkt_from_coords(coords, geom_type='point') for coords in pos_arr.tolist()) attrib = {'cover': 'float', 'cover_error': 'float'} attr_list = list({ 'cover': cover[0], 'cover_error': cover[1] } for cover in zip(cover_arr, cover_err_arr)) vector = Vector.vector_from_string(wkt_list, geom_string_type='wkt', out_epsg=4326, vector_type='point', attributes=attr_list, attribute_types=attrib, verbose=False) print(vector) vector.rasterize(outfile=outfile, pixel_size=[xpixel, ypixel], out_dtype=gdal.GDT_Float32, compress='lzw', attribute='cover')
attr_list.append(elem) count += 1 uniq, indices, inverse, count = np.unique(ar=latlon, axis=0, return_index=True, return_counts=True, return_inverse=True) print(uniq.shape) exit() vector = Vector.vector_from_string(wkt_list, spref_string=spref_str, spref_string_type='proj4', vector_type='point', attributes=attr_list, attribute_types=attr, verbose=True) print(vector) vector.write_vector(outfilename) ''' file0 = "D:/Shared/Dropbox/projects/NAU/landsat_deciduous/data/albedo_data/albedo_data_2000_2010_full_by_tc.csv" infile1 = "D:/Shared/Dropbox/projects/NAU/landsat_deciduous/data/FIRE/ak_fire/FireAreaHistory_gt500ha.shp" infile2 = "D:/Shared/Dropbox/projects/NAU/landsat_deciduous/data/FIRE/can_fire/NFDB_poly_20171106_gt500ha_ABoVE_geo.shp" vec1 = Vector(infile1) vec2 = Vector(infile2)
str(year), str(nfeat))) wkt_list = list() count = 0 feat = layer.GetNextFeature() while feat: new_geom = feat.GetGeometryRef() if new_geom.GetGeometryType() < 0: new_geom.FlattenTo2D() wkt_list.append(new_geom.ExportToWkt()) feat = layer.GetNextFeature() count += 1 vec.datasource.ReleaseResultSet(layer) temp_vec = Vector.vector_from_string(wkt_list, spref=vec.spref, vector_type='multipolygon') temp_lyr = temp_vec.layer temp_vec.rasterize(outfile=outfile, pixel_size=(pixel_size, pixel_size), extent=(x_min, y_max, x_max, y_min), burn_values=[year], all_touched=True, nodatavalue=0, compress='lzw') sys.stdout.write('Written {}!\n\n'.format(outfile))
attr_list = list() for i, row in enumerate(decid_frac_samp): elem = dict() for header in list(attribute_types): elem[header] = row[header] wkt = Vector.wkt_from_coords([row['longitude'], row['latitude']], geom_type='point') wkt_list.append(wkt) attr_list.append(elem) vector = Vector.vector_from_string(wkt_list, out_epsg=4326, vector_type='point', attributes=attr_list, attribute_types=attribute_types, verbose=True) print(vector) vector.write_vector(ini_outfile) exit() # extract all decid frac values for calculating histogram decid_frac_list = list(samp['decid_frac'] for samp in decid_frac_samp) # histogram calculation step = 1.0 / float(nbins) hist, bin_edges = np.histogram(decid_frac_list, bins=nbins) hist = hist.tolist()