Open femdias opened 1 year ago
I have the same problem, have you found a solution?
No :( I decided to switch to R, there I used the function idw from spatstat.
No :( I decided to switch to R, there I used the function idw from spatstat.
May i have your source code on your github?
I can not display it publically on GitHub, but if you send me an e-mail (fem.dias@hotmail.com) I can send you my code!
this is my email @.***
Pada tanggal Rab, 28 Des 2022 pukul 03.21 Felipe Macedo Dias < @.***> menulis:
I can not display it publically on GitHub, but if you send me an e-mail ( @.***) I can send you my code!
— Reply to this email directly, view it on GitHub https://github.com/yahyatamim/pyidw/issues/3#issuecomment-1366156849, or unsubscribe https://github.com/notifications/unsubscribe-auth/A47BRLUAHUZMTGUTHE4Q5E3WPNFWDANCNFSM6AAAAAARNR6K6Y . You are receiving this because you commented.Message ID: @.***>
I don't know why, but your email is censored to me, it is shown: "@.***".
Nevertheless, I with edit my code to help you understand. For making a IDW in R, I basically follow this guide: https://rpubs.com/Dr_Gurpreet/interpolation_idw_R
library(tidyverse)
library(sf)
# install.packages('gstat')
library(gstat)
#install.packages('spatstat')
library(spatstat)
library(raster)
#install.packages('leaflet')
library(leaflet)
# install.packages("wesanderson")
library(wesanderson)
# Reading your Polygons shapefile
Polygons<- sf::st_read("PATH\your_shapefile.shp")
# Reading your Points shapefile
Points = sf::st_read("Monografia\\Outputs\\Estabelecimentos_IPC.shp")
# Let's assume that you have the columns "Latitude" and "Longitude" for the geografical/space position
# and the column "Value" for the numerical values that you want to intepolate
# Extracting the maximun coordinates of your Polygon shapefile
min_x <- min(na.omit(st_coordinates(Polygons)[,'X']))
max_x <- max(na.omit(st_coordinates(Polygons)[,'X']))
min_y <- min(na.omit(st_coordinates(Polygons)[,'Y']))
max_y <- max(na.omit(st_coordinates(Polygons)[,'Y']))
# Creating an rectangle with the extrem point of your geometry (observation window)
obs_window <- owin(xrange=c(min_x, max_x), yrange=c(min_y, max_y))
# Creating a "point pattern object", with your Points shapefile.
# Documentation: https://www.rdocumentation.org/packages/spatstat/versions/1.64-1/topics/ppp
ppp_points <- spatstat::ppp( x = Points$Longitude, y = Points$Latitude,
marks = Points$Values, window = obs_window)
# With your point pattern object, you can do the IDW.
# "power" argument is where you choose which power to you want toin the IDW function (you can see it in the documentation: https://www.rdocumentation.org/packages/spatstat/versions/1.64-1/topics/idw).
# "at" argument is where you choose if you want to interpolate in the full observation window or only in the points of the Points shapefile.
# "dimyx" is really important: the bigger the number, the highest will the resolution of your interpolation be (3000 = grid of 3000x3000 pixels)
idw_values <- idw(ppp_points , power = 2, at="pixels", dimyx=3000) # dimensão de 3000x3000 pixels
# Converting into a raster
idw_raster <- raster(idw_values , crs= crs(Polygons))
# Saving raster
writeRaster(idw_raster, stringr::str_interp("PATH\\raster_name.tif"), overwrite=TRUE)
I hope this code can help you! Let me know if you need help
Here is the solution:
calculationExtent = gpd.read_file(bounds_fn)
geom =box(*calculationExtent.total_bounds)
gdf_bounds = gpd.GeoDataFrame({'geometry': [geom]}, crs=calculationExtent.crs)
gdf_bounds.to_file(new_bounds_fn)
Thank you!
Pada tanggal Sab, 4 Feb 2023 pukul 05.53 franz-waldner < @.***> menulis:
Here is the solution:
calculationExtent = gpd.read_file(bounds_fn) geom =box(*calculationExtent.total_bounds) gdf_bounds = gpd.GeoDataFrame({'geometry': [geom]}, crs=calculationExtent.crs) gdf_bounds.to_file(new_bounds_fn)
— Reply to this email directly, view it on GitHub https://github.com/yahyatamim/pyidw/issues/3#issuecomment-1416499844, or unsubscribe https://github.com/notifications/unsubscribe-auth/A47BRLSFL4Q57ZR4R7KYJXDWVWD5NANCNFSM6AAAAAARNR6K6Y . You are receiving this because you commented.Message ID: @.***>
Hello!
First of all, that's for creating this package!
I'm having a problem that I can't find a solution. My code is the following:
And the error is:
All files can be downloaded here: https://drive.google.com/drive/folders/19UTkWA4O6kfR-4sIaDTBbO2tc0hTCOjR?usp=sharing
Do you know who can I solve this problem?
Thanks in advance!