官术网_书友最值得收藏!

Preparing our data

From the currently opened vector layers, the GeoNames layer has the largest attribute table with the most kinds of attributes. However, as the extract does not contain headers, it is quite hard to work with it. Fortunately, CSV files can be edited as regular text files or as spreadsheets. As the first step, let's open the GeoNames file with a text editor and prepend a header line to it. It is tab delimited; therefore, we need to separate the field names with tabs. The field names can be read out from the readme file in order. In the end, we should have a first line looking something like this:

    geonameid name asciiname alternatenames latitude longitude
featureclass
featurecode countrycode cc2 admin1 admin2 admin3 admin4 population
elevation
dem timezone modification
If you use a text or code editor which replaces tabs with spaces, don't forget to switch off that feature before adding the header line. Furthermore, copy-pasting the preceding code block will probably not work.

Now we can remove our GeoNames layer from the layer tree and add it again. In the form, we have to check the option First record has field names. If we do so, and name the latitude and longitude fields accordingly, we can see QGIS automatically filling the X and Y fields:

You can speed up rendering and spatial querying by checking  Use spatial index. It will consume some memory though, so be careful with unusually large files. If you have such a big GeoNames layer that you cannot work with (like the whole U.S. table on a weaker computer), you can choose another layer for the next part.
主站蜘蛛池模板: 万荣县| 乐亭县| 宁南县| 禹城市| 板桥市| 浦城县| 金阳县| 浮山县| 吉隆县| 永寿县| 达日县| 安顺市| 积石山| 岳池县| 佳木斯市| 商水县| 丘北县| 二连浩特市| 大石桥市| 彰化市| 天气| 新兴县| 双牌县| 历史| 平果县| 济阳县| 莫力| 汝阳县| 尉犁县| 清丰县| 武胜县| 瑞丽市| 高阳县| 凌源市| 莆田市| 嘉鱼县| 肥乡县| 云霄县| 沁阳市| 从江县| 察隅县|