Hi Edzer,

Thanks for the swift reply. Unfortunately, already with installing the package 
something goes wrong. I get the following message:

*** arch - i386
rm -f RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_write.o geos.o 
proj.o wkb.o sf.dll
mkdir -p ../inst
"C:/PROGRA~1/R/R-33~1.2/bin/i386/Rscript.exe" "../tools/winlibs.R"
cp -r ../windows/gdal2-2.1.1/share/gdal ../inst/
cp: cannot stat '../windows/gdal2-2.1.1/share/gdal': No such file or directory
make: *** [winlibs] Error 1
Warning: running command 'make -f "Makevars.win" -f 
"C:/PROGRA~1/R/R-33~1.2/etc/i386/Makeconf" -f 
"C:/PROGRA~1/R/R-33~1.2/share/make/winshlib.mk" CXX='$(CXX1X) $(CXX1XSTD)' 
CXXFLAGS='$(CXX1XFLAGS)' CXXPICFLAGS='$(CXX1XPICFLAGS)' 
SHLIB_LDFLAGS='$(SHLIB_CXX1XLDFLAGS)' SHLIB_LD='$(SHLIB_CXX1XLD)' 
SHLIB="sf.dll" OBJECTS="RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o 
gdal_write.o geos.o proj.o wkb.o"' had status 2
ERROR: compilation failed for package 'sf'
* removing 'C:/Users/vandijkm/R/library/3.3.2/sf

It seems it is unable to find the gdal files. I have gdal installed but not in 
the .../Windows/ folder. Perhaps that is the problem?
Best,
Michiel

-----Original Message-----
From: R-sig-Geo [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Edzer 
Pebesma
Sent: 21 December 2016 16:23
To: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] Scaling coarse raster to finer raster using 
overlapping area weights

Hi Michiel,

in my first reply to this list yesterday I mentioned the function 
sf::st_interpolate_aw (area-weighted) which has an argument "extensive"
that has to be set to TRUE or FALSE; when TRUE, amounts are redistributed 
proportionality to the target area. It seems you have an extensive variable 
(amount), so you could use that.

For this you need to install package sf from source, by

devtools::install_github("edzer/sfr")

Both datasets need to be polygon. Let me know if it works, or when you have 
trouble getting it to work (more likely!)

Best regards,

On 21/12/16 16:06, Dijk, Michiel van wrote:
> Hi,
> 
> I hope you can help me with the following. I have a coarse raster (0.5 x 0.5 
> degree) with information on global water demand (WD), which I want to combine 
> with a higher resolution (5 arc min) global raster (which I have both in 
> raster and polygon format). The higher resolution raster contains the 
> locations of simulation units (SIMUs) that are related to a model. I would 
> like to redistribute the  global water demand raster over the SIMUs. I first 
> started with the 'resample' function in the raster package but this function 
> allocates the total value for water demand to the cells with smaller 
> resolution, resulting in much too large total water demand. What I am looking 
> for is some sort of weighted disaggregation of values in the water demand 
> raster to the SIMU raster using the share in overlapping area between cells 
> in the two rasters. 
> 
> For example:
> Suppose we have cell A in the water demand raster and this cell contains 
> SIMUa, SIMUb and SIMUc (which can have different sizes). I would like to 
> allocate the following value to SIMUa: Value in cell A x (Area SIMUa)/(Area 
> cell A). Off course the first problem is that it is very well possible that 
> only a part of SIMUa overlaps with Cell A so before I can start I need to (1) 
> find the overlap between the Water demand raster and the SIMU raster and (2) 
> calculate the area of SIMUa that overlaps with cell A. Here I already run 
> into problems. 
> 
> I looked on the web for solutions and came across similar issues but none of 
> it really worked. This post seems to come close:
> http://gis.stackexchange.com/questions/155701/overlaying-grids-with-a-
> polygon-to-determine-the-average-value-of-the-overlappin
> 
> however when I run the gInteresects command to find the overlap  I get the 
> following error: 
> 
> Error in RGEOSBinPredFunc(spgeom1, spgeom2, byid, func) : 
>   rgeos_binpredfunc_prepared: maximum returned dense matrix size 
> exceeded
> 
> I assume that this is a memory issue but I could not find any information on 
> the internet to solve this. Any recommendations to help me solve this 
> particular issue or suggestions on other/better solutions to down scale the 
> water demand raster are welcome. 
> 
> Many thanks,
> Michiel
> 
> 
> M. (Michiel) van Dijk, PhD
> Research scholar | Ecosystems Services and Management (ESM) | 
> International Institute for Applied Systems Analysis (IIASA) Senior 
> researcher (out of office) | International Policy Division (IB) | 
> Wageningen Economic Research
> 
> |Schlossplatz 1 - A-2361 Laxenburg, Austria, room s-138
> S +43 2236 807 537
> Skype: michiel.van.dijk
> S https://www.researchgate.net/profile/Michiel_Van_Dijk/
> / http://nl.linkedin.com/pub/michiel-van-dijk/1a/805/346
> 
> www.iiasa.ac.at
> www.wur.eu/economic-research
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

--
Edzer Pebesma
Institute for Geoinformatics  (ifgi),  University of Münster Heisenbergstraße 
2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to