georreferenced shapes from ImageJ to R

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

georreferenced shapes from ImageJ to R

hmorzaria
Hi,
I followed the instructions in the video to transfer georeferenced shapes to R.

https://www.youtube.com/watch?v=P2NflfBB2Tg



I have a georeferenced jpeg, I:
1. Open it
2. Convert into 8bit, specify treshold, analyze particles, select a region
3. Measure and transfer table to R

If I just send the selection as a SpatialPolygon dataframe to R it works.

But if I try to add a georeference it doesn't work. As the file to select for the georeference I tried selecting the original georeferenced JPEG, I tried saving as geotif.
The resulting output in R are two files (showing X, Y) that when plotted show one point.

What is the correct way to specify a georeference?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: georreferenced shapes from ImageJ to R

Marcel
The library which is used to georeference the SpatialPolgons is GDAL 1.7.1.

Eventually it can't be read. But geotiff should normally work. Do you get any error message in the
console? Do you have an example file which you can sent?

What do you get when you load the file with the script importer in the File->Import Scripts menu which load the info or the whole file?

Try again to convert the *.jpeg to a geotiff:, e.g. with rgdal, gdal or another GIS:

http://www.inside-r.org/node/229353

http://gis.stackexchange.com/questions/2312/how-can-i-transform-a-georeferenced-jpg-to-a-georeferenced-tif

If that doesn't work another alternative would be to load the *.jpeg with the import script (use the "Grid importer" import) and then georeference the SpatialPolygons after the transfer (if that is possible). Or in R simply by using the commands described here:

https://github.com/Bio7/Bio7_Workshop/blob/master/GeoreferencedData/ImageToProjectedRaster.R

To change the projection or apply a projection:

https://pakillo.github.io/R-GIS-tutorial/#changeproj

http://www.maths.lancs.ac.uk/~rowlings/Teaching/UseR2012/cheatsheet.html

http://gis.stackexchange.com/questions/18940/how-can-i-find-out-how-to-convert-this-point-to-lat-lon?lq=1



Reply | Threaded
Open this post in threaded view
|

Re: georreferenced shapes from ImageJ to R

hmorzaria
Hi:

Thanks for your help. I tried everything you suggested and it didn't work, the extent was incorrect or I couldn't preserve the spatial reference in the shapefile.

I did solve the problem, though.

My georeferenced JPEG file had a spatial reference in a geographic coordinate system (WGS 1984); it was not projected into a Projection Coordinate System.

http://gis.stackexchange.com/questions/149749/is-wgs84-a-coordinate-system-or-projection-system

Once I projected the JPEG (in my case to a Lambert projection) I was able to do obtain the polygon, transfer it in R, and save it as a shapefile with the correct extent and coordinate system.

Perhaps the bio7 manual should state that layers need to be projected in order to be able to transfer georeferenced data.
Reply | Threaded
Open this post in threaded view
|

Re: georreferenced shapes from ImageJ to R

Marcel
Good to hear that you found a solution. I will add a hint for the next release of the software.
Reply | Threaded
Open this post in threaded view
|

Re: georreferenced shapes from ImageJ to R

Marcel
In reply to this post by hmorzaria
The information has been added to the user guide.
Reply | Threaded
Open this post in threaded view
|

Re: georreferenced shapes from ImageJ to R

Bio7
Administrator
This post was updated on .
I have to improve my last two answers.

I was definitely able to transfer a default WGS84 geotiff without problems (projection automatically assigned, see last link):

proj4string :
[+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0]

So maybe some projection informations weren't available or an accompanying *.jpegw file was missing for GDAL, see:

https://en.wikipedia.org/wiki/World_file

http://www.gdal.org/frmt_jpeg.html

http://gis.stackexchange.com/questions/14692/help-required-to-convert-georeferenced-and-rectified-tiff-orthophotos-to-geore

See also for WGS84:

http://gis.stackexchange.com/questions/73576/what-is-the-projection-of-wgs84-in-gis-software