I've done tons of work within ArcGIS to analyze and process rasters. I'm pretty well knowledgeable on that subject. A question has come in from my coworker who is attempting to populate elevation data in his SQL server. The first question he asked was if its possible through code to connect to a raster and query it for data, kind of like connecting to an ODBC data source? The idea would be to query for data in an extent and then create records of elevation points within that area. Is that possible with a data driver?

Second, if he has a current version of SQL Server I believe that has some capability to store GIS data correct? Is there a possibility to load the raster into the SQL server as a table and then query it as you would any other table? Or does he require some GIS framework to do this?


  • We have stored raster 'images' in SQL server but not raster 'data'. We can query the images as records in a table, but we can't do pixel-level overlays, queries, etc. I can find out how it was done if you'd like... – DPSSpatial May 20 '15 at 20:47
  • Hmm maybe something like that except we need to query out of a huge raster only a smaller extent. Then for that extent get each cell value and it coordinates. These will then get pumped into another standard table. – sinDizzy May 20 '15 at 20:51
  • The guys down in BI did this for me but it was the first time I've heard of rasters in SQL server - they are stored as BLOB's I believe, but not georeferenced and thus not 'data'... so... this might not be an option in SQL Server. – DPSSpatial May 20 '15 at 20:54
  • We ll I dont necessarily want to store the raster in the SQL server. I just need some way to query the raster and get a subset of its data. The raster is just a file on our server that we add to ArcGIS and then use for analysis. What my coworker hopes to do is just to connect to the file and query it directly, then based on the data returned put that into a table with fields like Source, X, Y, Z. I don't think this is going to be possible. – sinDizzy May 20 '15 at 22:43
  • so you're not using SQL server really you're using ArcSDE to store the raster? – DPSSpatial May 20 '15 at 23:42

If you want to query by x & y coordinates, use Get Cell Value (Data Management) .

If you want to query by point features, you can use Sample (Spatial Analyst) or Extract Values to Points (Spatial Analyst).

If you want an array of raster values in an extent, you can use RasterToNumPyArray (arcpy).

| improve this answer | |
  • Let me give that last suggestion a try. That may be what I'm looking for and he may just have to bite the bullet and install ArcGIS on his machine. – sinDizzy May 21 '15 at 0:43
  • Or you can do it for him and show how brilliant you are. There are SQL raster functions if he's adamant not to install ArcGis, these are database specific and it can be difficult to use these values outside of SQL, this is probably a good time to gently influence him on the benefits of GIS software, ArcGis and your assistance. – Michael Stimson May 21 '15 at 1:33
  • I ended up giving him two options with sample code. using ArcObjects I can check out a license and run a raster query for any amount of coordinates. also using MapWindow (which may use GDAL in the background) also has some good raster API. – sinDizzy May 29 '15 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.