indexed tif images do not display
Dan Greve
grevedan at HOTMAIL.COM
Wed Jun 22 16:55:33 EDT 2005
I can never get relative paths in gdaltindex to work with mapserver. I
attached a program I use to change the gdaltindex shapefile based on a
simple pattern. Remove 'n' characters with pattern 'p'.
i.e. if all the records are /USA_Tiffs/something.tif
I do
gdaltirepath.exe -p f:/ -c 1 index.shp
will change all "location" (by default) records to
f:/USA_Tiffs/something.tif
I find it's quicker than rebuilding the entire shapefile using gdaltindex
which must open every file to be indexed. The -tileindex options permits
fields of other than 'location'
-- Dan Greve, Software Engineer
-- Palm Bay, FL
>From: Frank Warmerdam <fwarmerdam at GMAIL.COM>
>Reply-To: Frank Warmerdam <fwarmerdam at GMAIL.COM>
>To: MAPSERVER-USERS at LISTS.UMN.EDU
>Subject: Re: [UMN_MAPSERVER-USERS] indexed tif images do not display
>Date: Wed, 22 Jun 2005 12:18:24 -0400
>
>On 6/22/05, Ethan Alpert <ealpert at digitalglobe.com> wrote:
> > I think you need to rerun gdaltindex. I just did a dbf dump of mine and
> > realized that the paths to the tiles are absolute paths. Not sure if
> > there's a way to construct relative path tileindexes.
> >
> > Anyone?
>
>Ethan,
>
>gdaltindex will store the paths in the form they are passed in. So
>if you want relative paths, use those on the commandline.
>
>eg.
>
>gdaltindex index.shp doq/*.tif
>
>as opposed to
>
>gdaltindex index.shp /opt/data/doq/*.tif
>
>Of course, it can be tricky to ensure that the relative
>paths in the index file are correctly interpreted by mapserver.
>I'm never sure if it interpretes them relative to the index file,
>or the SHAPEPATH or what.
>
>Best regards,
>--
>---------------------------------------+--------------------------------------
>I set the clouds in motion - turn up | Frank Warmerdam,
>warmerdam at pobox.com
>light and sound - activate the windows | http://pobox.com/~warmerdam
>and watch the world go round - Rush | Geospatial Programmer for Rent
-------------- next part --------------
/******************************************************************************
* $Id: gdaltirepath.c,v 1.6 2004/04/02 17:33:22 greveda Exp $
*
* Project: ImagePick
* Purpose: Commandline App to correct shapefile records
* Author: Daniel Greve, grevedan @ hotmail.com
*
******************************************************************************
* Copyright (c) 2005 Daniel Greve
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: gdaltindex.c,v $
* Revision 1.1 2001/04/25 17:30:19 greveda
* New
*
*/
#include "ogrsf_frmts/shape/shapefil.h"
#include "gdal.h"
CPL_CVSID("$Id: gdaltirepath.c,v 1.6 2004/04/02 17:33:22 greveda Exp $");
/************************************************************************/
/* Usage() */
/************************************************************************/
static void Usage()
{
fprintf(stdout, "%s",
"\n"
"Usage: gdaltirepath [-c character_count] [-p pattern] "
"[-tileindex field_name] index_file [pattern] \n"
"\n"
"eg.\n"
" % gdaltirepath -p f:\\ -c 1 doq_index.shp \n"
"\n"
"NOTES:\n"
" o The default tile index field is 'location'.\n"
" o The values for records of field_name will have -c
characters\n"
" o removed and replaced with pattern -p.\n" );
exit(1);
}
/************************************************************************/
/* main() */
/************************************************************************/
int main(int argc, char *argv[])
{
const char *index_filename = NULL;
const char *tile_index = "location";
int i_replaceCount, i_shape;
char *replace_pattern = NULL;
char newAttribute[2048];
int i_arg, ti_field, ti_record;
SHPHandle hSHP;
DBFHandle hDBF;
GDALAllRegister();
argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 );
if( argc < 1 )
exit( -argc );
/* -------------------------------------------------------------------- */
/* Get commandline arguments other than the GDAL raster filenames. */
/* -------------------------------------------------------------------- */
for( i_arg = 1; i_arg < argc; i_arg++ )
{
if( strcmp(argv[i_arg],"-tileindex") == 0 )
{
tile_index = argv[++i_arg];
}
else if( strcmp(argv[i_arg], "-c") == 0 )
{
i_replaceCount = atoi(argv[++i_arg]);
}
else if( strcmp(argv[i_arg], "-p") == 0 )
{
replace_pattern = argv[++i_arg];
}
else if( argv[i_arg][0] == '-' )
Usage();
else if( index_filename == NULL )
{
index_filename = argv[i_arg];
i_arg++;
break;
}
}
if( index_filename == NULL )
Usage();
if( replace_pattern == NULL )
printf("No pattern provided. Will delete %d characters\n",
i_replaceCount);
/* -------------------------------------------------------------------- */
/* Open the target shapefile and DBF file. */
/* -------------------------------------------------------------------- */
hSHP = SHPOpen( index_filename, "r+" );
if( hSHP == NULL )
{
fprintf( stderr, "Unable to open/create shapefile `%s'.\n",
index_filename );
exit(2);
}
hDBF = DBFOpen( index_filename, "r+" );
if( hDBF == NULL )
{
fprintf( stderr, "Unable to open/create DBF file `%s'.\n",
index_filename );
exit(2);
}
for( ti_field = 0; ti_field < DBFGetFieldCount(hDBF); ti_field++ )
{
char field_name[16];
DBFGetFieldInfo( hDBF, ti_field, field_name, NULL, NULL );
if( strcmp(field_name, tile_index) == 0 )
break;
}
if( ti_field == DBFGetFieldCount(hDBF) )
{
fprintf( stderr, "Unable to find field `%s' in DBF file `%s'.\n",
tile_index, index_filename );
exit(2);
}
/* -------------------------------------------------------------------- */
/* loop over records, processing. */
/* -------------------------------------------------------------------- */
ti_record = DBFGetRecordCount(hDBF);
for(i_shape = 0 ; i_shape < ti_record; i_shape++ )
{
const char *oldAttribute = DBFReadStringAttribute( hDBF, i_shape, ti_field
);
memset(newAttribute, 0, sizeof(char) * 2048);
strcpy( newAttribute, replace_pattern );
strncat( newAttribute, oldAttribute + i_replaceCount, strlen(oldAttribute)
- i_replaceCount );
DBFWriteStringAttribute( hDBF, i_shape, ti_field, newAttribute );
}
DBFClose( hDBF );
SHPClose( hSHP );
exit( 0 );
}
More information about the mapserver-users
mailing list