Re: [gdal-dev] extra spaces when writing to AAIGRID format
Brad, > E.g., if I try to write a 3x3 grid that ArcGIS can read, it needs to look > something like this: > > ncols 3 > nrows 3 > xllcorner 100. > yllcorner 100. > cellsize 0.1000 > 1.0 1.4809201955795288 1.4809201955795288 > 0.11773009598255157 0.15476560592651367 0.86710774898529053 > 0.17429724335670471 0.76037305593490601 10.00 > > Instead, the ascii file written by GDAL looks like this (which can't be read > by ArcGIS because of extra leading spaces in the first line of the data): What is the ArcGIS error? I tried these files on ArcMap 9.3 and 10.0 and had no issues that I realized. (to display in a meaningful manner, I had to change the symbology which required the calculation of statistics in ArcGIS. I also changed the cellsize to .1 so I could more easily examine the pixels and values.) Below looks like a 3x4 grid that is labeled as 5x5 but even that worked for me in ArcGIS (didn't throw error but values were not where 'expected'). > > > ncols 5 > nrows 5 > xllcorner 100. > yllcorner 100. > cellsize 0.1000 > 1 1.4809201955795288 1.4809201955795288 > 0.25947147607803345 0.71342569589614868 2.810183288701 > 0.11773009598255157 0.15476560592651367 0.86710774898529053 > 0.17429724335670471 0.76037305593490601 10 0.74458205699920654 > All 4 of of Even's files worked for me too. HTH, Eli ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Some tables from mdb not exported to PostGIS
Assuming that you are using ogr2ogr on the xp computer, you can fairly easily setup ODBC connections for the non-spatial tables, http://gdal.org/ogr/drv_odbc.html Doing the same from linux is somewhat more difficult, the easiest path I think to be http://gdal.org/ogr/drv_mdb.html You can see some of my previous similar attempts, http://lists.osgeo.org/pipermail/gdal-dev/2011-November/030833.html And this general topic seems to be ongoing so which version you are using may be relevant depending on specifics, http://trac.osgeo.org/gdal/changeset/23931 Bests, Eli On Fri, Jan 27, 2012 at 6:50 PM, jjap wrote: > Greetings, > ogr2ogr has allowed me to successfully convert an ESRI personnal geodatabase > from a Windows XP computer to an Ubuntu server 11.04 running PostGIS 1.5 > with proper encoding . The tables containing the blob/shapefiles all made it > but not the others. Am I right to presume I'll have to migrate those other > tables by hand and rebuild references? > Am I missing some options which would have allowed me to do it in one fell > swoop? Any hints appreciated. > > -- > View this message in context: > http://osgeo-org.1560.n6.nabble.com/Some-tables-from-mdb-not-exported-to-PostGIS-tp4344999p4344999.html > Sent from the GDAL - Dev mailing list archive at Nabble.com. > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] OGR SQL CAST and field name alias selects incorrect fields in some cases
Hi all, I'm trying to use OGR SQL to CAST and field name aliasing together and getting incorrect results (or issuing incorrect commands) when combined with two LEFT JOINs on MDB (both ODBC and MDB drivers). The results are incorrect in that the fields are populated with incorrect information, specially, filling it with other fields that are not selected at all. I'm seeing this in windows close to trunk (ODBC) and a statically compiled ubuntu 10.04 trunk from a few months ago (Access MDB/Java/Jackess). The data is somewhat messy so it could be a case of ambiguous table/query names after some shortening is applied or something similar although nothing jumps out in that regard to me. Both the tables that are joined to have a field named DocumentName. Also, the way I am using the CAST in this case isn't needed but I ran into it and wanted to report it. The simple case works as I expect: ogr2ogr surveys_simply_cast2.shp Surveys.shp -sql "SELECT CAST(surveyid AS character(255)) AS surveyid_alias, COMMENT FROM Surveys" Warning 6: Normalized/laundered field name: 'surveyid_alias' to 'surveyid_a' Specifically, I get a field named surveyid_a that is character 255 and has the correct content: ogrinfo -al -so surveys_simply_cast2.shp surveys_simply_cast2 ... surveyid_a: String (255.0) COMMENT: String (15.0) Now I try the same thing with two LEFT JOINs to mdb/ODBC: ogr2ogr surveys_output_two_fields.shp Surveys.shp -sql "SELECT CAST(webimage AS character(255)) AS webimage_1, CAST(SubdivisionName AS character(255)) AS Subdivisio FROM Surveys LEFT JOIN 'ODBC:cygwinSurveys'.Local_Survey_Image ON Surveys.surveyid=Local_Survey_Image.DocumentName LEFT JOIN 'ODBC:cygwinSurveys'.Survey ON Surveys.surveyid=Survey.DocumentName" Warning 6: Field FileDate create as date field, though DateTime requested. This gives me the fields that I expect: ogrinfo -al -so surveys_output_two_fields.shp surveys_output_two_fields ... webimage_1: String (255.0) Subdivisio: String (255.0) However, they are populated with incorrect information. The field webimage_1 is filled with values from the field cygwinSurveys.Survey.Comments. The field Subdivisio is filled with values from cygwinSurveys.Survey.ImagePilot (or Net_PDF - yes there are two fields with identical information). Adding --debug ON shows that these tables don't have FID columns (I could not see all the debug content but that seemed to be the only non-routine information): OGR_ODBC: Table Local_Survey_Image has no identified FID column. ... On Ubuntu, the results are the same, my command is: LD_LIBRARY_PATH=.:/usr/lib/jvm/java-6-openjdk/jre/lib/i386/client ogr2ogr /tmp/surveys_etl/surveys.shp /tmp/surveys_etl/Surveys.shp -sql " SELECT Surveys.surveyid AS SURVEYID,DocumentName AS DocumentNa,SurveyorKey as SurveyorKe,CAST(webimage AS character(255)) AS webimage_1,FileDate,Client, SurveyType,ClerkNumber AS ClerkNumbe,CAST(SubdivisionName AS character(255)) AS Subdivisio FROM Surveys LEFT JOIN '/tmp/surveys_etl/Surveys.mdb'.Survey ON Surveys.surveyid=Survey.DocumentName LEFT JOIN '/tmp/surveys_etl/Surveys.mdb'.Local_Survey_Image ON Surveys.surveyid=Local_Survey_Image.DocumentName" Excluding the CAST gives the correct results: ogr2ogr surveys_output_no_cast.shp Surveys.shp -sql "SELECT webimage AS webimage_1, SubdivisionName AS Subdivisio FROM Surveys LEFT JOIN 'ODBC:cygwinSurveys'.Local_Survey_Image ON Surveys.surveyid=Local_Survey_Image.DocumentName LEFT JOIN 'ODBC:cygwinSurveys'.Survey ON Surveys.surveyid=Survey.DocumentName" Trying to reintroduce the CAST with only one join works correctly (for either join): ogr2ogr surveys_output_singel_join.shp Surveys.shp -sql "SELECT CAST(webimage AS character(255)) AS webimage_1 FROM Surveys LEFT JOIN 'ODBC:cygwinSurveys'.Local_Survey_Image ON Surveys.surveyid=Local_Survey_Image.DocumentName" ogr2ogr surveys_output_singleb.shp Surveys.shp -sql "SELECT CAST(SubdivisionName AS character(255)) AS Subdivisio FROM Surveys LEFT JOIN 'ODBC:cygwinSurveys'.Survey ON Surveys.surveyid=Survey.DocumentName" I can package this up for download by anyone interested, just contact me offline for the link. (I can also include the statically compiled binary as well although it may only work on Ubuntu 10.04 with Java/Jackess/etc and called setting LD_LIBRARY_PATH.) Bests, Eli ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] gdal post - boundary polygone for rectified images
Gianluca, > Or if just there is a way to create a vector file showing the boundary of > the rectified image. > What I am searching is a script in "gdal style" in order to automate the > procedure for several rasters without further user input. OGR has tindex which makes a shapefile outline of rasters, http://gdal.org/ogrtindex.html HTH, Eli ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Re: Slope in gdaldem
Steve, > additional processing steps they can. How does adding code to gdal work? Just from an observer perspective, it seems that once you have your additions worked out, attach a diff on on trac ticket. The details for how to do that are: sign up for an osgeo userid, http://www.osgeo.org/osgeo_userid (if you don't already have one), login to the gdal trac and then open a new ticket, http://trac.osgeo.org/gdal/report I don't know the likelihood of one of the developers adding it in, someone might comment on the ticket about that (could depend on the code, impacts to other parts, etc). Putting it in a ticket also makes it available to anyone that may want to locally apply it for themselves. HTH, Eli > Best, > Steve > > > float GDALSlopeHydroAlg (float* afWin, float fDstNoDataValue, void* pData) > > { > // Hydrologic Slope is the max > // local slope btw center cell and adjacent cells > > const double radiansToDegrees = 180.0 / M_PI; > GDALSlopeAlgData* psData = (GDALSlopeAlgData*)pData; > double key; > > float pafLocalMin = afWin[0]; > > float pafLocalMax = afWin[0]; > > for ( int k = 1; k < 9; k++) > { > if (afWin[k] < pafLocalMin) > { > pafLocalMin=afWin[k]; > > } > > if (afWin[k] > pafLocalMax) > { > pafLocalMax=afWin[k]; > } > > } > > key = afWin[4] - pafLocalMin; > > if (key < 0) > { > key = afWin[4] - pafLocalMax; > > } > > if (psData->slopeFormat == 1) > return (float) (atan(sqrt(key) / (2*psData->scale)) * > radiansToDegrees); > else > return (float) (100*(sqrt(key) / (2*psData->scale))); > } > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] ogr2ogr creates empty shape files
Wolfgang, > how would one prevent OGR2OGR from creating an empty target files > when a WHERE condition returns no records from the source files? This I know that there is a COUNT() that can be used in the SELECT part. I've never tried it in the WHERE part. You might be able to try that. > question came up during a batch process where dozens or even hundreds of files > are converted and further processed. Is there an option besides of > manually deleting those files? Depending on how you are doing your batch process, you can use ogrinfo with COUNT() as a test to decide if you should do the ogr2ogr part. HTH, Eli > TIA > > wolfgang > > > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Re: strange behaviour with gdalwarp and LZW compression
Stefano, I think that is expected. You can read a little more about it and a recommended work around (VRT) here, http://trac.osgeo.org/gdal/wiki/UserDocs/GdalWarp#GeoTIFFoutput-coCOMPRESSisbroken Bests, Eli >> The problem arise if I insert the options -co COMPRESS=LZW at the >> warping. The process end successfully but the resulting geotiff is 6 >> times the size of the original one! >> ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Re: strange behaviour with gdalwarp and LZW compression
Reading further, I learn about OPTIMIZE_SIZE, http://gdal.org/structGDALWarpOptions.html#a0ed77f9917bb96c7a9aabd73d4d06e08 Can OPTIMIZE_SIZE be set from the command line? Eli On Tue, Mar 6, 2012 at 3:41 PM, Eli Adam wrote: > Stefano, > > I think that is expected. You can read a little more about it > and a recommended work around (VRT) here, > http://trac.osgeo.org/gdal/wiki/UserDocs/GdalWarp#GeoTIFFoutput-coCOMPRESSisbroken > > Bests, Eli > >>> The problem arise if I insert the options -co COMPRESS=LZW at the >>> warping. The process end successfully but the resulting geotiff is 6 >>> times the size of the original one! >>> ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Ogr2OGR for GeoJSON fails on windows 7
Vivek, I think you might have some minor typos: > ogr2ogr -f "geoJSAON CENO.json CENOVUS.shp "GeoJSON" not "geoJSAon [no ending double quote either] HTH, Eli ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Ogr2OGR for GeoJSON fails on windows 7
Vivek, > My bad , i did typo in writing here. I have written correctly as GeoJSON for > conversion. Are you saying that you typed it correctly on the command line and it still doesn't work? If so, can you copy your command and error from the command line to the email? Eli ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] bring through shapefile attribute in gdal_rasterize
Derek, > This may be a simple question for most of you but I thought I would > ask it anyhow as I am at an impasse. I have a Counties shape file. I > am attempting to convert it to raster utilizing gdal_rasterize, and > this does work. However, I am attempting to carry into the output > file the county name preferably e.g. Orange County, or at least a > county identify of some kind. I have utilized a command similar to > the following: > > gdal_rasterize -a COUNTY -l -sql "select COUNTY, * from Counties" > Counties Counties.shp CountiesRaster.tif I think that -l should specify the layer name from the source dataset not the field. Typically in a shapefile there is only one layer and it is the same as the shapefile name. Try dropping the -l stuff all together. gdal_rasterize -a COUNTY Counties.shp CountiesRaster.tif or if you use it, use it like this: gdal_rasterize -a COUNTY -l Counties Counties.shp CountiesRaster.tif > > However, when I open the resulting raster file in ArcGIS and click on > one of the pixel to identify it I don’t see the county name. Is the > county name there and I am just not seeing it in ArcGIS indentify. I > realize there are probably more GDAL intensive ways to check for the > data, but I am still learning. I was hoping to someone could explain > to me what I am doing incorrectly. You can get information from a raster in GDAL with gdallocationinfo. HTH, Eli > > Thanks, > Derek > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] to find area of shapeFile
I'm just guessing here since not much of an email or question made it through. You can look at this, http://gdal.org/ogr/ogr_sql.html, specifically OGR_GEOM_AREA HTH, Eli On Tue, Jun 12, 2012 at 4:21 AM, SIVA RAMA KRISHNA wrote: > > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] to find area of shapeFile
Siva, I'm not sure how to help you with the below code. Perhaps if you explain the error someone else on the list might be able to help. My suggestion was how to get the area using the command line tool ogr2ogr. Regards, Eli On Thu, Jun 14, 2012 at 1:16 AM, SIVA RAMA KRISHNA wrote: > Eli Adam, > > i am Trying To Find Area of A Polygon > with the Following Code > > int main() > { > OGRRegisterAll(); > OGRLayer *poLayer; > OGRFeature *poFeature; > OGRDataSource *poDS; > poDS = OGRSFDriverRegistrar::Open( "first.shp"); > poLayer = poDS->GetLayerByName( "first"); > int nCount=poDS->GetLayerCount(); > printf("%d",nCount); > poLayer->ResetReading(); > OGRGeometry *poGeometry; > OGRGeometryCollection *PoGC; > while((poFeature=poLayer->GetNextFeature())!=NULL) > { > int nCnt=poFeature->GetFieldCount(); > printf("\n %d",nCnt); > qDebug()<<"entered"; > poGeometry=poFeature->GetGeometryRef(); > if(poGeometry !=NULL > && wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon) >{ > PoGC->addGeometry(poGeometry); > double area = PoGC->get_Area() ; > qDebug() << area ; > } > } > return 0; > } > > i am getting Error > With Regards > siva > ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Updating shapefile "fields" name with ogr2ogr
I've also found this very confusing and unexpected. Once I did figure it out it has been very useful. Could ogrinfo CHEMIN.shp -sql "ALTER TABLE CHEMIN RENAME COLUMN prec_alti TO foo" or similar be added as an example to http://gdal.org/ogrinfo.html and perhaps also as a 'note about ogrinfo with OGR SQL' on http://gdal.org/ogr/ogr_sql.html? Perhaps http://gdal.org/ogr/ogr_sql.html could be updated from: -sql statement: Execute the indicated SQL statement and return the result. to something like: -sql statement: Execute the indicated SQL statement and return the result. In place updates (ALTER TABLE) are also permitted. Eli On Thu, Jun 21, 2012 at 11:03 PM, Hermann Peifer wrote: > On 2012-06-20 19:50, Even Rouault wrote: >> >> >> I know this is going to sound a bit counter-intutive at first... >> >> ogrinfo opens datasources in read/write mode by default... > > > Just out of curiosity: why does an ...info tool use read/write mode by > default? One would expect that it only needs to *read* some info in the data > source? > > Hermann > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev